package com.ckerchina.admin.ckadmin.utils;

import java.text.SimpleDateFormat;  
import java.util.Date;
import java.util.Random;  
  
public class GenOrder extends Thread{  
  
    private static long orderNum = 0l;  
    private static String date ;  
      
    public static void main(String[] args) throws InterruptedException {  
        for (int i = 0; i < 1000; i++) {  
            System.out.println(GenOrder.getOrderNo());  
            Thread.sleep(1);  
        }  
    }  
  
    /** 
     * 生成订单编号 
     * @return 
     */  
	public static synchronized String getOrderNo() {
		int max = 9999;
		int min = 1000;
		Random random = new Random();
		int s = random.nextInt(max) % (max - min + 1) + min;	
		String str = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
		long orderNo = Long.parseLong((str)) * 1000;
		orderNo += s;
		return orderNo + "";
	}
  
} 
